home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / pmap.arc / PMAP.DOC next >
Text File  |  1987-04-11  |  18KB  |  394 lines

  1.  
  2.                                    PMAP 1.21
  3.                                    ---------
  4.  
  5.         PMAP (Program MAP) is a simple program that displays how your
  6.         PC's memory is being used.  It lists all active programs
  7.         (including resident programs such as Sidekick and PCED) and
  8.         tells you how much free memory is available for programs.  If
  9.         expanded (LIM) memory is present, a summary of EMS use is also
  10.         shown.
  11.  
  12.         Syntax summary
  13.         --------------
  14.  
  15.             pmap            (display memory usage)
  16.             pmap /d         (display detailed memory usage)
  17.             pmap /r         (display raw memory allocation chain)
  18.  
  19.  
  20.         Standard display
  21.         ----------------
  22.  
  23.         When PMAP is invoked without parameters, you'll see a display
  24.         like this:
  25.  
  26.          Addr  Program    Parent   Parameters    Blks    Size    Vectors
  27.          ----  -------   --------  -----------   ----   -------  -------
  28.          1470  command   command                    2      3632  22 23 24 2E
  29.          155C  rxintmgr  command                    2      1408  60
  30.          15B6  sdump     command                    2      2816  05
  31.          1666  kbfix2    command   /KT1 /D0...      2      2560  08 09 16
  32.          1708  fastvr    command                    2       576
  33.          172E  ced       command   ??               2     26976  1B 61
  34.          1DC6  raw       command   ??               2       688
  35.          1DF4  cache-em  command   /1312 /t         2     28848  13 19 21
  36.          Total conventional free memory             1    503888
  37.          Largest conventional free block                 503888
  38.          Next program will load at 2500
  39.  
  40.         Each program that is currently in memory is displayed.  Fields
  41.         are as follows:
  42.  
  43.             Addr        The memory segment at which the program is
  44.                         loaded, in hexadecimal.
  45.  
  46.             Program     The name of the program, if available.  "??"
  47.                         indicates that the name is not available.  The
  48.                         program name is never available under DOS 2.x.
  49.  
  50.             Parent      The name of the program's "parent".  In most
  51.                         cases, this will be "command", because most
  52.                         programs are run by COMMAND.COM (i.e., from
  53.                         the DOS prompt).  See below.
  54.  
  55.             Parameters  The command line parameters that were specified
  56.                         when the program was run.  Some programs re-use
  57.                         the area where the parameters are stored, in
  58.                         which case a "??" will be displayed.  An
  59.                         ellipsis ("...") at the end indicates that there
  60.                         were more parameters than could fit here.
  61.  
  62.             Blocks      The number of memory blocks that are owned by
  63.                         the program.
  64.  
  65.             Size        The total size of all blocks owned by the
  66.                         program.
  67.  
  68.  
  69.             Vectors     A list of 80x8x interrupt vectors that appear to
  70.                         have been "intercepted" by the program.
  71.  
  72.         For example, the program KBFIX2 is loaded at memory segment
  73.         1666H and was run directly from the DOS prompt.  The original
  74.         parameters were "/KT1 /D0" and there were more parameters than
  75.         can be shown here.  DOS has allocated two blocks of memory for
  76.         the program, and they total 2560 bytes in size.  Vectors 8
  77.         (timer tick), 9 (keyboard interrupt), and 16 (keyboard service)
  78.         have been "intercepted" by KBFIX2.
  79.  
  80.         At the end of the list, PMAP indicates the number of blocks of
  81.         free memory, the total size of all free blocks, the largest
  82.         single free block, and the segment address at which the next
  83.         program will probably load.
  84.  
  85.         NOTE: "below" the first program loaded in memory (usually
  86.         COMMAND.COM), there is a block of memory allocated by DOS for
  87.         device drivers, etc.  PMAP does not show this block in its
  88.         standard display.  If you are interested to see how large it is
  89.         and where it is allocated, use the /R display described below,
  90.         in which it will be the first block listed; it will usually show
  91.         0008 in the "owner" field.
  92.  
  93.  
  94.         Detail display
  95.         --------------
  96.  
  97.         When you run PMAP with the /D (Detail) parameter, you'll see the
  98.         same display, except that PMAP will show a detailed list of
  99.         memory blocks allocated for each program.  For example:
  100.  
  101.          Addr  Program    Parent     Parameters  Blks    Size    Vectors
  102.          ----  -------   --------  ------------------   -------  -------
  103.          1666  kbfix2    command   /KT1 /D0...      2      2560  08 09 16
  104.          1661  Environment                                   64
  105.          1666  Program                                     2496
  106.  
  107.         KBFIX2 has two memory blocks allocated to it; PMAP shows the
  108.         size of each block and its address, and makes an educated guess
  109.         as to what the block is used for.
  110.  
  111.         PMAP also displays a detail list of all free blocks of memory.
  112.  
  113.  
  114.         Raw display
  115.         -----------
  116.  
  117.         When you run PMAP with the /r (Raw) parameter, you'll see a
  118.         display like this:
  119.  
  120.             T  MCB  Addr  Owner  Para    Bytes
  121.             - ----  ----  -----  ----  --------
  122.             M 0974  0975   0008  0AFA     44960
  123.             M 146F  1470   1470  00C3      3120
  124.             M 1533  1534   1470  0020       512
  125.                [more of the same]
  126.             M 1DF3  1DF4   1DF4  0706     28768
  127.             M 24FA  24FB   2500  0004        64 [pmap]
  128.             M 24FF  2500   2500  1376     79712 [pmap]
  129.             Z 3876  3877   0000  6789    424080
  130.  
  131.         This is an uninterpreted list of all blocks of memory allocated
  132.         by DOS (see below).  The fields are as follows:
  133.  
  134.             Type        The block type.  There are only two block types,
  135.                         type M and type Z.  The last block in the
  136.                         chain is type Z, and all others are type M.
  137.  
  138.             MCB         The segment address of the Memory Control Block
  139.                         (sometimes known as an arena header).
  140.  
  141.             Addr        The segment address of the memory block itself.
  142.                         This is always equal to the MCB address plus
  143.                         one.
  144.  
  145.             Owner       The segment address of the program that "owns"
  146.                         the block of memory.  If this is 0000, the block
  147.                         is unallocated or "free".
  148.  
  149.             Para        The size of the block, in paragraphs (16 bytes).
  150.  
  151.             Bytes       The size of the block, in bytes.
  152.  
  153.         All numbers are hexadecimal except "bytes", which is decimal.
  154.  
  155.         The [pmap] suffix after an allocated block indicates that the
  156.         block is being used by PMAP.  When PMAP terminates, this block
  157.         will be free (unallocated).  The standard (non-Raw) PMAP display
  158.         understands this, and displays the map as if PMAP weren't there.
  159.  
  160.  
  161.         Expanded memory display
  162.         -----------------------
  163.  
  164.         If expanded (LIM-EMS, or EEMS) memory is present, PMAP always
  165.         displays EMS allocation as follows:
  166.  
  167.                     Expanded memory summary:
  168.  
  169.                     Block      Size
  170.                     -----    -------
  171.                     0          98304
  172.                     1        1409024
  173.                     Free           0
  174.                     Total    1507328
  175.                     Page frame segment: CC00h
  176.  
  177.         Like standard DOS memory, EMS memory is allocated in blocks.
  178.         However, no information is easily available regarding the blocks
  179.         except their sizes, so that is all that is displayed.
  180.  
  181.         EMS memory uses a "page frame" that maps a 64K block (actually,
  182.         four 16K "pages") of EMS memory into standard 80x8x memory.
  183.         The segment to which this memory is mapped is also displayed.
  184.  
  185.  
  186.         Interrupt vectors
  187.         -----------------
  188.  
  189.         Many times interrupts are "intercepted" by more than one
  190.         resident program.  PMAP will only show a vector attached to the
  191.         LAST program that intercepted it.  For example, KBFIX2 shows
  192.         that it has intercepted vectors 8, 9, and 16.  However, RXINTMGR
  193.         and SDUMP could also have intercepted any or all of these three
  194.         vectors, and PMAP would not know about that.
  195.  
  196.         PMAP assumes that any vector that points into memory owned by a
  197.         program has been intercepted by that program.  That is not
  198.         always true, so you may occasionally see spurious vectors
  199.         attached to a program.
  200.  
  201.  
  202.         More about parents
  203.         ------------------
  204.  
  205.         Every program has a "parent"; if program B was executed by
  206.         program A, then A is B's parent.  In most cases, the parent will
  207.         be COMMAND.COM, because most PC programs are executed by
  208.         COMMAND.COM.
  209.  
  210.         However, any program can execute any other program (assuming
  211.         that there is sufficient memory, etc.).  This is how "shells"
  212.         work.  For example, current versions of WordPerfect and many
  213.         other programs allow you to "exit to DOS"; what they usually do
  214.         is execute COMMAND.COM, which then displays a DOS prompt and
  215.         allows you to enter any commands that you wish.  If you run
  216.         PMAP, you will see two copies of COMMAND.COM in memory.
  217.  
  218.         However, you may notice that the second copy of COMMAND.COM
  219.         shows COMMAND.COM as its parent.  Logically, you would expect
  220.         the parent to be (in this case) WordPerfect.  Unfortunately,
  221.         some versions of COMMAND.COM (the one that comes with DOS 3.2,
  222.         for example) fool around with the area of memory that PMAP uses
  223.         to find the parent's address; rather than having the parent's
  224.         address, COMMAND.COM puts its own address there.  In effect,
  225.         COMMAND.COM is always its own parent.
  226.  
  227.         In general, programs that allow you to execute other programs
  228.         can use one of two methods: they can execute the other programs
  229.         directly, or the can execute COMMAND.COM and ask it to run the
  230.         requested program.  If the former, PMAP will show the true
  231.         parent; if the latter, PMAP will show COMMAND.COM, and
  232.         COMMAND.COM will be its own parent.
  233.  
  234.         Here is part of a PMAP display that shows a direct-execution
  235.         under DOS 3.2:
  236.  
  237.             Addr  Program    Parent   Blks    Size    Vectors
  238.             ----  -------   --------  ----   -------  -------
  239.             ...
  240.             3222  xced      command      2     26016
  241.             387E  qe        xced         3     97232
  242.             503E  command   command      3      3488  22 23 24
  243.             ...
  244.  
  245.         The XCED program was run by COMMAND.COM (from the DOS prompt).
  246.         It then ran the program QE directly, i.e., without reloading
  247.         COMMAND.COM.  Finally, a "shell" exit was taken from QE, which
  248.         did reload COMMAND.COM; notice that COMMAND shows as its own
  249.         parent.
  250.  
  251.  
  252.         Multi-tasking/task-switching programs
  253.         -------------------------------------
  254.  
  255.         ... play havoc with the memory allocation chain.  PMAP may
  256.         not yield very much useful information under such programs.
  257.  
  258.  
  259.         DOS's memory allocation chain
  260.         -----------------------------
  261.  
  262.         This information is almost totally undocumented by Microsoft, so
  263.         take it for what's it's worth.  It's provided for informational
  264.         purposes only, and could vary from DOS version to DOS version.
  265.  
  266.         DOS (version 2.00 or later) manages memory as a chain of
  267.         "blocks".  Each block begins on a paragraph boundary, can be (in
  268.         theory) almost a megabyte in size, and is preceded immediately
  269.         by a 16-byte Memory Control Block (MCB), sometimes known as an
  270.         "arena header".  The very lowest portions of memory (containing
  271.         the 80x8x interrupt vectors, BIOS and DOS data areas, DOS
  272.         itself, device drivers, etc.) are not mapped, but all of the rest
  273.         of memory is.  Thus, memory can be pictured like this:
  274.  
  275.             paragraph   contents
  276.             ---------
  277.               0000      low memory (unmapped)
  278.                         first MCB (16 bytes)
  279.                         first memory block
  280.                         next MCB
  281.                         next memory block
  282.                         ...
  283.                         last MCB
  284.                         last memory allocation block
  285.               nnnn      end of DOS memory
  286.  
  287.         The address of the first MCB will vary, depending on your
  288.         version of DOS, and the number and size of device drivers,
  289.         buffers, stacks, etc., that you loaded via CONFIG.SYS.  In all
  290.         current versions of DOS (through 3.21), the segment address of
  291.         the first MCB can be obtained via DOS function 52H.  On return
  292.         from this function, the address of the first MCB is located at
  293.         ES:[BX-2].  Here is sample code that returns the address of the
  294.         first MCB in AX:
  295.  
  296.             mov ah,52H
  297.             int 21H
  298.             mov ax,es:[bx-2]
  299.  
  300.         The MCB itself is a 16-byte region of memory that with fields as
  301.         follows:
  302.  
  303.             Offset  Size    Contents
  304.             ------  ----    --------
  305.             0       Byte    'M': this is not the last MCB
  306.                             'Z': this is the last MCB
  307.                             anything else: memory control blocks
  308.                             destroyed.  DOS will politely crash.
  309.  
  310.             1       Word    The segment address of the program that owns
  311.                             this block of memory (the program's PSP).
  312.  
  313.             3       Word    The size of the block, in paragraphs
  314.  
  315.             5-15            Reserved
  316.  
  317.         This structure provides all of the information needed to step
  318.         through the memory allocation chain.  A basic algorithm is as
  319.         follows:
  320.  
  321.             Set MCB = segment of first MCB (as described above)
  322.             Do Until byte (MCB:0) = 'Z'
  323.                 If byte (MCB:0) isn't 'M' or 'Z',
  324.                     Then there's a big problem
  325.                 Block_owner = word (MCB:1)
  326.                 Block_size = word (MCB:3)
  327.                 MCB = MCB + block_size + 1
  328.             End
  329.  
  330.         EMS and EEMS memory is not, of course, mapped by DOS.
  331.  
  332.         For more complete detail about DOS's memory allocation, see
  333.         "Managing Memory" by William J. Redmond in PC Tech Journal,
  334.         August, 1984 (Vol. 2, No. 2).
  335.  
  336.  
  337.         Version 1.21
  338.         ------------
  339.  
  340.         Bug fixes to version 1.20:
  341.  
  342.         1. No more runaway display when EMS memory is present but none
  343.         of it is in use.
  344.  
  345.         2. PMAP is more careful about what it thinks is the name of the
  346.         command shell.
  347.  
  348.  
  349.         Copyright/License/Warranty
  350.         --------------------------
  351.  
  352.         This document and the program file PMAP.EXE ("the software") are
  353.         copyrighted by the author.  The copyright owner hereby licenses
  354.         you to: use the software; make as many copies of the program and
  355.         documentation as you wish; give such copies to anyone; and
  356.         distribute the software and documentation via electronic means.
  357.         There is no charge for any of the above.
  358.  
  359.         However, you are specifically prohibited from charging, or
  360.         requesting donations, for any such copies, however made; and
  361.         from distributing the software and/or documentation with
  362.         commercial products without prior permission.  An exception is
  363.         granted to not-for-profit user's groups, which are authorized to
  364.         charge a small fee (not to exceed $7) for materials, handling,
  365.         postage, and general overhead.  NO FOR-PROFIT ORGANIZATION IS
  366.         AUTHORIZED TO CHARGE ANY AMOUNT FOR DISTRIBUTION OF COPIES OF
  367.         THE SOFTWARE OR DOCUMENTATION, OR TO INCLUDE COPIES OF THE
  368.         SOFTWARE OR DOCUMENTATION WITH SALES OF THEIR OWN PRODUCTS.
  369.  
  370.         THIS INCLUDES A SPECIFIC PROHIBITION AGAINST FOR-PROFIT
  371.         ORGANIZATIONS DISTRIBUTING THE SOFTWARE, EITHER ALONE OR WITH
  372.         OTHER SOFTWARE, AND CHARGING A "HANDLING" OR "MATERIALS" FEE OR
  373.         ANY OTHER SUCH FEE FOR THE DISTRIBUTION.  NO FOR-PROFIT
  374.         ORGANIZATION IS AUTHORIZED TO INCLUDE THE SOFTWARE ON ANY MEDIA
  375.         FOR WHICH MONEY IS CHARGED.  PERIOD.
  376.  
  377.         There is no restriction on the use of this software in
  378.         commercial or institutional environments.
  379.  
  380.         No copy of the software may be distributed or given away without
  381.         this document; and this notice must not be removed.
  382.  
  383.         There is no warranty of any kind, and the copyright owner is not
  384.         liable for damages of any kind.  By using this free software,
  385.         you agree to this.
  386.  
  387.         The software and documentation are:
  388.  
  389.                           Copyright (C) 1986, 1987 by
  390.                             Christopher J. Dunford
  391.                            10057-2 Windstream Drive
  392.                            Columbia, Maryland 21044
  393.                                 (301) 992-9371
  394.